package com.cssl.controller;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ModelAttribute;

import com.cssl.vo.UserVo;

/**
 * 全局
 * @author tym
 *
 */
@ControllerAdvice(basePackages = "com.cssl.controller")
public class MyAdvice {
	
	@ExceptionHandler(Exception.class)
	public String error(Exception e) {
		System.out.println("全局异常:"+e.getMessage());
		return "error";
	}
	
	@ModelAttribute
	public UserVo model(UserVo uvo) {
		System.out.println("model:"+uvo);
		uvo.setUname("匿名用户");
		return uvo;
	}

}
